use std::fs::File;
use std::io::Read;
use std::path::Path;
use serde::Deserialize;
use serde_yaml::from_slice;

#[derive(Debug, Deserialize)]
pub struct Config {
    pub(crate) git: GitConfig,
}

#[derive(Debug, Deserialize)]
pub struct GitConfig {
    pub h5: String,
    pub micro: String,
}

pub fn read_file(path: &Path) -> Result<Config, Box<dyn std::error::Error>> {
    let mut file = File::open(path)?;

    // 读取文件内容到Vec<u8>
    let mut contents = Vec::new();
    file.read_to_end(&mut contents)?;

    // // 将文件内容解析为Config结构体
    let config: Config = from_slice(&contents)?;
    Ok(config)
}